package com.bdqn.spark.chapter05.value

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark05_RDD_Operator_Transform {
  def main(args: Array[String]): Unit = {

    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("operator-glom")
    val sc = new SparkContext(sparkConf)

    val sourceRDD: RDD[Int] = sc.makeRDD(List(1, 2, 3, 4), 2)
    // 1, 2, 3, 4
    // [1 2]  -> int
    // [3 4]  -> int

    // glom

    // Array(1,2) -> Array
    // Array(3,4) -> Array

    val rdd: RDD[Array[Int]] = sourceRDD.glom()
    rdd.collect.foreach(arr=>{
      println(arr.mkString(","))
    })




    sc.stop()
  }
}
